package com.yicheng.controller;

import com.yicheng.controller.utils.R;
import com.yicheng.entity.Image;
import com.yicheng.service.ImageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("images")
public class ImageController {
    @Autowired
    private ImageService imageService;

    @GetMapping("/getImages")
    public R getImage(Integer cate){
        R r = new R();
        try {
            List<Image> imageList = imageService.getImages(cate);
            r.setList(imageList);
            r.setMsg("获取该种类图片成功");
        }catch (Exception e){

            r.setMsg(e.getMessage());
            r.setStatus(false);
        }
        return r;
    }

}
